pr=$2
pi=$1
base_source=https://minio.itime.biz:4443/downloads/os/smartos
if [ "${pi}" == "" ]; then
        echo """usage:
        $0 20220127T011500Z
        $0 20220127T011500Z 20220127"""
        exit -1
fi
[[ "${pr}" != "" ]] || pr=${pi:0:8}
if [ "${base_source}" == "" ]; then
    source=${pi}
fi

if [ "${pr}" == "-i" ]; then
    [[ "${source}" != "" ]] || source=${base_source}/${pi}/smartos-${pi}.iso
    piadm -v bootable -e -i ${source} zones
else
    [[ "${source}" != "" ]] || source=${base_source}/${pi}/platform-release-${pr}-${pi}.tgz
    piadm -v install ${source} zones
fi
piadm -v activate ${pi}